package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.SysRoleMenuService;
import com.atguigu.spzx.model.dto.system.AssignMenuDto;
import com.atguigu.spzx.model.vo.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/admin/system/sysRoleMenu")
@Tag(name = "用户角色接口")
public class SysRoleMenuController {
    @Autowired
    private SysRoleMenuService sysRoleMenuService;

    @GetMapping("/findSysRoleMenuByRoleId/{roleId}")
    @Operation(summary = "查看指定角色的菜单")
    public Result<Map<String, Object>> findSysRoleMenuByRoleId(@PathVariable Long roleId){
        Map<String, Object> sysRoleMenuList = sysRoleMenuService.findSysRoleMenuByRoleId(roleId);

        return Result.OK(sysRoleMenuList);
    }

    @PostMapping("/doAssign")
    @Operation(summary = "分配指定角色菜单列表")
    public Result doAssign(@RequestBody AssignMenuDto assignMenuDto){
        sysRoleMenuService.doAssign(assignMenuDto);
        return Result.OK(null);
    }
}
